#ifndef CSGGRAPHER_H
#define CSGGRAPHER_H

#include "tree/tree.h"
#include "CSG/csgnode.h"
#include "QGLWidget"
#include "QFile"

class CSGGrapher
{
public:
    CSGGrapher();
    ~CSGGrapher();

    void createCSGTree(CSGNode * root);

    void initial();

    // get & set
    bool getGrid(){return grid;}
    void setGrid(bool g){grid = g;}
    void setCSGTree(Tree<int> *tree);
    Tree<int> *getCSGTree(){return csgTree;}

    // test
    bool ptInSet(double *pt);

    // draw
    void drawBoundingBox();
    void drawCtrlPolygon();
    void drawContour();
    void drawNaively();
    void drawCasteljau(int level = 5);

    double x0, x1, y0, y1, z0, z1; /* domaine d'afficahge de la courbe */
    int niv_recursion;
    int dim;
    bool grid;
    bool isoSurf;

private:
    Tree<int> * csgTree;
};

int yylex();
int yyparse();
int yyerror( char *s);

Expression exprX();
Expression exprY();
Expression exprZ();

double * new_point(double x = 0.0, double y = 0.0, double z = 0.0);
// double ** initial_pt_array(double * pt);
double ** add_pt_to_array(double **pt_array, double *pt);
void releasePtArray(double **pt_array);

extern CSGGrapher * grapher;
extern int debug_grapher;

#endif // CSGGRAPHER_H
